public class test3 {
    //力扣  75.颜色分类
    public void sortColors(int[] nums) {
        int len = nums.length;
        int left = -1,right = len;
        for(int i = 0;i<right;){
            if(nums[i]==0){
                left++;
                swap(nums,left,i);
                i++;
            }else if(nums[i]==1){
                i++;
            }else{
                right--;
                swap(nums,right,i);
            }
        }
    }
    public void swap(int[] nums,int a,int b){
        int temp = nums[a];
        nums[a] = nums[b];
        nums[b] = temp;
    }
}
